<template>
  <div>
    <router-view/>

    <van-tabbar v-model="active" placeholder route>
      <van-tabbar-item icon="home-o" to="/home/shou">首页</van-tabbar-item>
      <van-tabbar-item icon="apps-o" to="/home/classify">分类</van-tabbar-item>
      <van-tabbar-item icon="cart-o" @click="goCart">购物车</van-tabbar-item>
      <van-tabbar-item icon="contact" to=
      "/home/mine">我的</van-tabbar-item>
    </van-tabbar>

  </div>
</template>

<script>
import { Dialog } from "vant";
export default {
  data() {
    return {
      active: 0
    };
  },
  watch: {},

  components: {},

  computed: {},

  mounted() {},

  methods: {
    goCart() {
      // 判断有没有登录
      if (localStorage.getItem("token")) {
        this.$router.push("/home/cart");
      } else {
        Dialog.confirm({
          title: "请先登录"
        })
          .then(() => {
            this.$router.push("/login");
          })
          .catch(() => {
            // on cancel
          });
      }
    }
  }
};
</script>

<style lang="less" scoped></style>
